package com.xiaoming;

import java.util.concurrent.ThreadLocalRandom;

public class ClientBootStrap {

    public static void main(String[] args) throws Exception {
        RpcConsumer rpcConsumer = new RpcConsumer();
        UserService proxy = (UserService) rpcConsumer.createProxy(UserService.class);
        for (int i = 0; true; i++) {
            Thread.sleep(2000);
            User user = new User();
            user.setAge(i);
            boolean b = ThreadLocalRandom.current().nextBoolean();
            user.setGender("女");
            if (b) {
                user.setGender("男");
            }
            user.setName("张" + +i);
            user.setId(i);
            if(rpcConsumer.isReady()){
                Object o = proxy.sayHello(user);
                System.out.println(o);
            }else {
                System.out.println("准备中.....");
                Thread.sleep(2000);
            }
        }
    }
}
